
import 'package:fyi/model/history_model.dart';
import 'package:fyi/net/http_client.dart';

class BindDao{
  static Future<bool> bind(String licensePlate,String headerNo,String carriageNo)async{
    var result = await HttpClient.post("Driver/bindCar",data: {"licensePlate":licensePlate,"headerNo":headerNo,"carriageNo":carriageNo});
    if(result?.isSuccess()){
      return true;
    }
    throw Exception('绑定失败');
  }

  static Future<bool> unbind(String carId)async{
    var result = await HttpClient.post("Driver/unbindingCar",data: {"carId":carId});
    if(result?.isSuccess()){
      return true;
    }
    throw Exception('解绑失败');
  }

  static Future<List<HistoryModel>> histories()async{
    var result = await HttpClient.post("Driver/bindingHistory");
    if(result?.isSuccess()){
      var data = result.data;
      var model = HistoryListModel.fromJson(data);
      return model?.resultList;
    }
    throw Exception('获取历史失败');
  }
}